//
//  KLBookListCollectionViewCell.m
//  KLBookCollection
//
//  Created by apple on 2017/11/5.
//  Copyright © 2017年 bonc. All rights reserved.
//

#import "KLBookListCollectionViewCell.h"

@implementation KLBookListCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)initSubViews {
    self.contentView.backgroundColor = UIColorFromHexRGB(0xF9F9F9);
    
    self.coverImageView = [[UIImageView alloc] init];
    self.coverImageView.backgroundColor = [UIColor whiteColor];
    self.coverImageView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:self.coverImageView];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:10.0f];
    self.titleLabel.textColor = UIColorFromHexRGB(0x555555);
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:self.titleLabel];
    
    NSDictionary *views = NSDictionaryOfVariableBindings(_coverImageView, _titleLabel);
    
    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-5-[_coverImageView]-5-|" options:NSLayoutFormatAlignAllTop metrics:nil views:views]];
    
    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-5-[_coverImageView]-1-[_titleLabel(==30)]-5-|" options:NSLayoutFormatAlignAllLeft | NSLayoutFormatAlignAllRight metrics:nil views:views]];
}

- (void)prepareForReuse {
    [super prepareForReuse];
    
    self.titleLabel.text = nil;
    self.coverImageView.image = nil;
    
}

- (void)setSelected:(BOOL)selected {
    [super setSelected:selected];
    
}


@end
